<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/views/common/includetag.jsp"%> 

<!DOCTYPE html>
<html lang="en_US">
    <head>
        <title><spring:message code="app.user.title" /></title>
    </head>
    
    <body>
        <div class="clearfix"></div>
        
        <div class="row back-top-title">
			<div class="col-md-12">
				<span>版本管理</span>
			</div>
		</div>
		
		<form style="position:relative" id="splitPage" action="${contextPath}/appVersion" method="POST" role="form" class="form-horizontal">
			<div class="row">
				<div class="col-md-12">
					<div class="panel panel-white">
						<div class="panel-body">
							<div class="row">
								 <div class="col-md-12 space20">
									<a href="#none" class="btn btn-primary btn-add">
										<i class="fa fa-plus"></i>
										添加
									</a>
								 </div>
							</div>
							
							<div class="table-responsive">
								<table id="dataTable" class="table table-striped table-bordered table-hover table-full-width">
                                    <thead>
                                        <tr>
                                            <th sortColumn="versionNumber">版本编号</th>
                                            <th sortColumn="type">类型</th>
                                            <th sortColumn="updateLog">更新日志</th>
                                            <th><spring:message code="app.common.action.operate" /></th>
                                            <th></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <c:forEach items="${pagination.datas}" var="user" varStatus="s">
                                            <tr data-id="${appVersion.id}">
                                                <td><c:out value="${appVersion.versionNumber}" /></td>
                                                <td><c:out value="${appVersion.type}" /></td>
                                                <td><c:out value="${appVersion.updateLog}" /></td>
                                                <td>
                                                    <a href="${contextPath}/appVersion/edit?id=${user.id}" class="btn btn-info btn-sm"><spring:message code="app.common.action.edit" /></a>
                                                    <a href="#none" class="btn btn-danger btn-sm btn-delete"><spring:message code="app.common.action.delete" /></a>
                                                </td>
                                            </tr>
                                        </c:forEach>
                                    </tbody>
                                </table>
                                <div class="row" id="splitPageDiv">
									<jsp:include page="/views/common/splitPage.jsp">
										<jsp:param value="mainPanel" name="divId"/>
										<jsp:param value="splitPage" name="formId"/>
										<jsp:param value="splitPageDiv" name="splitPageDiv"/>
									</jsp:include>
								</div>
                            </div>
						</div>
					</div>
				</div>
			</div>
		</form>
		
        <script type="text/javascript">
	        $(function(){
	        	$('.btn-add').click(function(){
	        		location.href = '${contextPath}/appVersion/add';
	        	});
	        	
	        	$('.btn-delete').click(function(){
	        		var roleId = $(this).parents('tr').attr('data-id');
	        		if(roleId){
	        			BootstrapDialog.confirm({
	        				title: '删除提示',
	        	            message: '确认删除？',
	        	            btnCancelLabel: '取消',
	        	            btnOKLabel: '确认',
	        	            callback: function(f){
	        	            	if(f){
	        	            		$.ajax({
	        	        				type: 'POST',
	        	        				url: '${contextPath}/appVersion/delete/exec',
	        	        				data: {'id': roleId},
	        	        				success: function(result){
	        	        					if(result){
	        	        						var r = $.parseJSON(result);
	        	        						if(r && r.resultCode == '000000'){
	        	        							location.href = contextPath + '/appVersion';
	        	        						}
	        	        					}
	        	        				}
	        	        			});
	        	            	}
	        	            }
	        			});
	        		}
	        	});
	        });
	    </script>
    </body>
</html>